﻿using System;
using System.IO;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;

// Token: 0x020002EA RID: 746
public class GameControl : MonoBehaviour
{
	// Token: 0x170001BE RID: 446
	// (get) Token: 0x060012FF RID: 4863 RVA: 0x000894A8 File Offset: 0x000876A8
	// (set) Token: 0x06001300 RID: 4864 RVA: 0x000894B0 File Offset: 0x000876B0
	public bool IsHideUI { get; set; }

	// Token: 0x170001BF RID: 447
	// (get) Token: 0x06001301 RID: 4865 RVA: 0x000894BC File Offset: 0x000876BC
	// (set) Token: 0x06001302 RID: 4866 RVA: 0x000894C4 File Offset: 0x000876C4
	public bool IsWhiteMoz { get; private set; }

	// Token: 0x170001C0 RID: 448
	// (get) Token: 0x06001303 RID: 4867 RVA: 0x000894D0 File Offset: 0x000876D0
	// (set) Token: 0x06001304 RID: 4868 RVA: 0x000894D8 File Offset: 0x000876D8
	public int State { get; private set; }

	// Token: 0x170001C1 RID: 449
	// (get) Token: 0x06001305 RID: 4869 RVA: 0x000894E4 File Offset: 0x000876E4
	// (set) Token: 0x06001306 RID: 4870 RVA: 0x00089510 File Offset: 0x00087710
	public bool ShowFPS
	{
		get
		{
			return this.fpsCanvas != null && this.fpsCanvas.gameObject.activeInHierarchy;
		}
		set
		{
			if (this.fpsCanvas != null)
			{
				this.fpsCanvas.gameObject.SetActive(value);
			}
		}
	}

	// Token: 0x170001C2 RID: 450
	// (get) Token: 0x06001307 RID: 4871 RVA: 0x00089534 File Offset: 0x00087734
	public bool IsActiveModalUI
	{
		get
		{
			return this.modalUI != null;
		}
	}

	// Token: 0x06001308 RID: 4872 RVA: 0x00089544 File Offset: 0x00087744
	private void Awake()
	{
		this.InstallCheck();
		Time.timeScale = this.timeScale;
		if (this.TargetFPS > 0)
		{
			Application.targetFrameRate = this.TargetFPS;
		}
		UnityEngine.Object.DontDestroyOnLoad(base.gameObject);
		if (QualitySettings.GetQualityLevel() == 0)
		{
			Shader.globalMaximumLOD = 500;
		}
		else
		{
			Shader.globalMaximumLOD = int.MaxValue;
		}
		Shader.WarmupAllShaders();
		this.sceneCtrl = new SceneControl();
		this.IsHideUI = false;
		this.IsWhiteMoz = false;
		this.State = 0;
	}

	// Token: 0x06001309 RID: 4873 RVA: 0x000895CC File Offset: 0x000877CC
	private void Start()
	{
	}

	// Token: 0x0600130A RID: 4874 RVA: 0x000895D0 File Offset: 0x000877D0
	private void Update()
	{
		this.ShowFPS = ConfigData.showFPS;
		this.Update_Key();
	}

	// Token: 0x0600130B RID: 4875 RVA: 0x000895E4 File Offset: 0x000877E4
	private void Update_Key()
	{
		if (EventSystem.current != null && EventSystem.current.currentSelectedGameObject != null)
		{
			return;
		}
		if (Input.GetKeyDown(KeyCode.Space))
		{
			this.IsHideUI = !this.IsHideUI;
		}
	}

	// Token: 0x0600130C RID: 4876 RVA: 0x00089634 File Offset: 0x00087834
	public void CreateModalMessageUI(string text, Action<bool> yesAct = null, bool againCheck = false)
	{
		ModalMessage modalMessage = UnityEngine.Object.Instantiate<ModalMessage>(this.modalMessage_original);
		modalMessage.gameObject.SetActive(true);
		modalMessage.SetUp(text, yesAct, againCheck);
		this.modalUI = modalMessage;
	}

	// Token: 0x0600130D RID: 4877 RVA: 0x0008966C File Offset: 0x0008786C
	public void CreateModalYesNoUI(string text, Action yesAct, Action noAct = null)
	{
		ModalYesNo modalYesNo = UnityEngine.Object.Instantiate<ModalYesNo>(this.modalYesNo_original);
		modalYesNo.gameObject.SetActive(true);
		modalYesNo.SetUp(text, yesAct, noAct);
		this.modalUI = modalYesNo;
	}

	// Token: 0x0600130E RID: 4878 RVA: 0x000896A4 File Offset: 0x000878A4
	public void CreateModalInputStringUI(bool isFileName, string text, Action<string> enterAct, Action cancelAct = null, bool enableBlank = false, string def = "")
	{
		ModalInput modalInput = UnityEngine.Object.Instantiate<ModalInput>(this.modalInput_original);
		modalInput.gameObject.SetActive(true);
		modalInput.SetUp(isFileName, text, enterAct, cancelAct, enableBlank, def);
		this.modalUI = modalInput;
	}

	// Token: 0x0600130F RID: 4879 RVA: 0x000896E0 File Offset: 0x000878E0
	public void CreateModalChoices(string text, string[] choices, Action[] acts)
	{
		ModalChoices modalChoices = UnityEngine.Object.Instantiate<ModalChoices>(this.modalChoices_original);
		modalChoices.gameObject.SetActive(true);
		modalChoices.SetUp(text, choices, acts);
		this.modalUI = modalChoices;
	}

	// Token: 0x06001310 RID: 4880 RVA: 0x00089718 File Offset: 0x00087918
	public void OnModelClose()
	{
		this.modalUI = null;
	}

	// Token: 0x06001311 RID: 4881 RVA: 0x00089724 File Offset: 0x00087924
	private void OnApplicationPause(bool pauseStatus)
	{
	}

	// Token: 0x06001312 RID: 4882 RVA: 0x00089728 File Offset: 0x00087928
	private void OnApplicationQuit()
	{
	}

	// Token: 0x06001313 RID: 4883 RVA: 0x0008972C File Offset: 0x0008792C
	public void AddState(GameControl.STATE state)
	{
		this.State |= (int)state;
	}

	// Token: 0x06001314 RID: 4884 RVA: 0x0008973C File Offset: 0x0008793C
	public void SubState(GameControl.STATE state)
	{
		if ((this.State & (int)state) != 0)
		{
			this.State ^= (int)state;
		}
	}

	// Token: 0x06001315 RID: 4885 RVA: 0x0008975C File Offset: 0x0008795C
	public bool CheckState(GameControl.STATE state)
	{
		return (this.State & (int)state) != 0;
	}

	// Token: 0x06001316 RID: 4886 RVA: 0x0008976C File Offset: 0x0008796C
	private void OnValidate()
	{
		if (this.timeScale > 0f)
		{
			Time.timeScale = this.timeScale;
		}
	}

	// Token: 0x06001317 RID: 4887 RVA: 0x0008978C File Offset: 0x0008798C
	public void ChangeScene(string scene, string msg = "", float fadeTime = -1f)
	{
		if (fadeTime < 0f)
		{
			fadeTime = this.FadeTime;
		}
		this.sceneCtrl.Change(scene, msg, this.FadeColor, fadeTime, 0f, false);
	}

	// Token: 0x06001318 RID: 4888 RVA: 0x000897BC File Offset: 0x000879BC
	public bool CheckInput()
	{
		foreach (Selectable selectable in Selectable.allSelectables)
		{
			InputField inputField = selectable as InputField;
			if (inputField != null && inputField.isFocused)
			{
				return false;
			}
		}
		return true;
	}

	// Token: 0x06001319 RID: 4889 RVA: 0x00089838 File Offset: 0x00087A38
	private void InstallCheck()
	{
		Directory.SetCurrentDirectory(Application.dataPath + "/../");
	}

	// Token: 0x04001815 RID: 6165
	public Color FadeColor = Color.black;

	// Token: 0x04001816 RID: 6166
	public float FadeTime = 0.5f;

	// Token: 0x04001817 RID: 6167
	public int TargetFPS = -1;

	// Token: 0x04001818 RID: 6168
	public SceneControl sceneCtrl;

	// Token: 0x04001819 RID: 6169
	public AudioControl audioCtrl;

	// Token: 0x0400181A RID: 6170
	public Canvas fpsCanvas;

	// Token: 0x0400181B RID: 6171
	public ModalYesNo modalYesNo_original;

	// Token: 0x0400181C RID: 6172
	public ModalMessage modalMessage_original;

	// Token: 0x0400181D RID: 6173
	public ModalInput modalInput_original;

	// Token: 0x0400181E RID: 6174
	public ModalChoices modalChoices_original;

	// Token: 0x04001822 RID: 6178
	private ModalUI modalUI;

	// Token: 0x04001823 RID: 6179
	[SerializeField]
	private float timeScale = 1f;

	// Token: 0x04001824 RID: 6180
	public Material mirrorDummy;

	// Token: 0x04001825 RID: 6181
	public string installRegistry = "Software\\illusion\\PlayHome";

	// Token: 0x020002EB RID: 747
	public enum STATE
	{
		// Token: 0x04001827 RID: 6183
		NONE
	}
}
